<?php


$values = $db->db_query("SELECT
							products_options_values_id,
							products_options_values_name
						FROM
							".TABLE_PRODUCTS_OPTIONS_VALUES."
						WHERE
							products_options_values_id = '".$_GET['value_id']."'
						AND
							language_id = '".$_SESSION['languages_id']."'");
?>
<tr>
	<td colspan="3" class="pageHeading"><?php echo $values->fields['products_options_values_name']; ?></td>
	<td>&nbsp;</td>
</tr>
<tr>
	<td>
		<table border="0" width="100%" cellspacing="0" cellpadding="2">
		<?php
		$products = $db->db_query("SELECT
										p.products_id,
										pd.products_name,
										po.products_options_name
									FROM
										".TABLE_PRODUCTS." p,
										".TABLE_PRODUCTS_ATTRIBUTES." pa,
										".TABLE_PRODUCTS_OPTIONS." po,
										".TABLE_PRODUCTS_DESCRIPTION." pd
									WHERE
										pd.products_id = p.products_id
									AND
										pd.language_id = '".$_SESSION['languages_id']."'
									AND
										po.language_id = '".$_SESSION['languages_id']."'
									AND
										pa.products_id = p.products_id
									AND
										pa.options_values_id='".$_GET['value_id']."'
									AND
										po.products_options_id = pa.options_id
									ORDER BY
										pd.products_name");
		if($products->_numOfRows) { ?>
			<tr class="dataTableHeadingRow">
				<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_ID; ?></td>
				<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCT; ?></td>
				<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_OPT_NAME; ?></td>
			</tr>
			<?php
			while (!$products->EOF) { $rows++; ?>
				<tr class="<?php echo (floor($rows/2) == ($rows/2) ? 'attributes-even' : 'attributes-odd'); ?>">
					<td align="center"><?php echo $products->fields['products_id']; ?></td>
					<td><?php echo $products->fields['products_name']; ?></td>
					<td><?php echo $products->fields['products_options_name']; ?></td>
				</tr>
			<?php
				$products->MoveNext();
			}
			?>
			<tr>
				<td colspan="3">
					<?php echo TEXT_WARNING_OF_DELETE; ?>
				</td>
			</tr>
			<tr>
				<td align="right" colspan="3">
					<?php echo button_link(BUTTON_CANCEL, href_link(FILENAME_PRODUCTS_ATTRIBUTES, $val_add));?></td>
			</tr>
		<?php } else { ?>
			<tr>
				<td colspan="3">
					<?php echo TEXT_OK_TO_DELETE; ?>
				</td>
			</tr>
			<tr>
				<td align="right" colspan="3">
					<?php echo button_link(BUTTON_DELETE, href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'action=delete_value&value_id='.$_GET['value_id'].'&'.$val_add.'&value_tab=1')); ?> 
					<?php echo button_link(BUTTON_CANCEL, href_link(FILENAME_PRODUCTS_ATTRIBUTES, $val_add.'&value_tab=1'));?>
				</td>
			</tr>
		<?php } ?>
		</table>